<template>
  <el-dialog
    class="batchModify"
    destroy-on-close
    center
    v-model="visible"
    :title="dialogDatas.title"
    width="40%"
    @closed="onReset"
  >
    <el-form :model="dialogDatas" ref="formRef" class="px12">
      <el-col v-for="item in dialogDatas.datas" :key="item.label">
      <el-form-item :label="item.label">
        <el-input
            v-if="item.type == 'input'"
            v-model="item.value"
            :placeholder="item.placeholder"
            disabled
          />
          <el-select
            v-if="item.type == 'select'"
            v-model="item.value"
            :multiple="item.Ttype=='multiple'"
            :placeholder="item.placeholder"
            :disabled="isDisabled"
          >
            <el-option
              :label="option.name"
              :value="option.id"
              v-for="option in item.options()"
              :key="option.id"
            />
          </el-select>
      </el-form-item>
    </el-col>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="visible = false">取消</el-button>
        <el-button type="primary" @click="onConfirm">确认</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, reactive, nextTick,watch } from 'vue';
import type { FormInstance } from 'element-plus';
import type { IRoleItem } from '@/api/role/type';
// import { batchChangeOwner } from '@/api/checkPointEquipment';

const emits = defineEmits(['onConfirm']);

const visible = ref(false);
const formRef = ref<FormInstance>();
const dialogDatas = reactive({});
const init = async (data?: IRoleItem) => {
  visible.value = true;
  if (data) {
    // await nextTick();
    Object.assign(dialogDatas, data);
    console.log(dialogDatas,'dialogDatas子页面-----=======');

  }
};
const onReset = () => {
  if (!formRef.value) return;
  formRef.value.resetFields();
};

const onConfirm = () => {
  const data = {
  resignId: dialogDatas.rowData.orgId,
  // extendId: dialogDatas.datas[1].value
  extendId:1116
  };
  visible.value = false;
  // dialogDatas
  emits('onConfirm',data,'lzjc',dialogDatas);
};
defineExpose({ init });
</script>

<style lang="scss">
.batchModify {
  .el-form-item {
    display: inline-block;
  }
  .el-form-item__content {
    width: 200px;
  }
}
</style>
